<template>
  <div>
    <div class="collapse_warps">
      <div class="collapse_warp">
        <a-icon type="caret-right" v-show="!boxshow" class="collapse" @click="boxshow = !boxshow" />
        <a-icon class="collapse" type="caret-down" v-show="boxshow" @click="boxshow = !boxshow" />
        <div class="title" @click="boxshow = !boxshow">
          {{ title }}
        </div>
        <div class="transverse" />
        <a-button v-if="showBtns && edit" slot="right" :disabled="disabled" type="link" :icon="icon" @click="$emit('edit')">
          {{ editText }}
        </a-button>
      </div>
      <div v-show="boxshow">
        <slot></slot>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      default: ""
    },
    edit: {
      type: Boolean,
      default: true
    },
    disabled: {
      type: Boolean,
      default: false
    },
    icon: {
      type: String,
      default: "form"
    },
    editText: {
      type: String,
      default: "编辑"
    },
    showBtns: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      boxshow: true
    };
  },
  methods: {
    isBoxshow() {
      this.boxshow = true;
    }
  }
};
</script>

<style lang="scss" scoped>
.box {
  height: 200px;
  width: 200px;
  background-color: black;
}
.draw-enter-active,
.draw-leave-active {
  transition: all 1s ease;
}
.draw-enter,
.draw-leave-to {
  height: 0;
}
.collapse {
  font-size: 20px;
  color: #c2c2c2;
}
.collapse_warp {
  display: flex;
  justify-content: space-between;
  align-items: center;
  .title {
    padding: 0 5px;
    display: block;
    margin-right: 15px;
    font-size: 16px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #252525;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    cursor: pointer;
  }
  .transverse {
    background-color: #e8e8e8;
    width: 100%;
    height: 1px;
    flex: 1;
  }
}
.collapse_warps {
  margin: 20px 0;
}
</style>
